using System.Linq;
using Headsight.BPMN2WF.Testing.TestObjCtors;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Headsight.BPMN2WF.BPMN.Schemas
{
    [TestClass]
    public class ExtensionsTest
    {
        private tProcessCtor _tProcessCtor;
        private tFlowNode _tFlowNode1;
        private tFlowNode _tFlowNode2;
        private tSequenceFlow _tSeqFlow1;
        private tSequenceFlow _tSeqFlow2;

        [TestInitialize]
        public void SetUp()
        {
            _tProcessCtor = new tProcessCtor();
            _tFlowNode1 = new tFlowNodeCtor().Create();
            _tFlowNode2 = new tFlowNodeCtor().Create();
            _tSeqFlow1 = new tSequenceFlowCtor().Create();
            _tSeqFlow2 = new tSequenceFlowCtor().Create();
        }

        [TestMethod]
        public void GetTFlowNodes_in_case_of_Items_is_null()
        {
            var sut = _tProcessCtor.Create();
            sut.Items = null;

            var actual = sut.GetTFlowNodes();

            Assert.IsNotNull(actual);
            Assert.AreEqual(0, actual.Count());
        }

        [TestMethod]
        public void GetTSequenceFlows_in_case_of_Items_is_null()
        {
            var sut = _tProcessCtor.Create();
            sut.Items = null;

            var actual = sut.GetTSequenceFlows();

            Assert.IsNotNull(actual);
            Assert.AreEqual(0, actual.Count());
        }

        [TestMethod]
        public void GetTFlowNodes_in_case_of_Items_is_empty()
        {
            var sut = _tProcessCtor.Create();
            sut.Items = new tFlowElement[0];

            var actual = sut.GetTFlowNodes();

            Assert.IsNotNull(actual);
            Assert.AreEqual(0, actual.Count());
        }

        [TestMethod]
        public void GetTSequenceFlows_in_case_of_Items_is_empty()
        {
            var sut = _tProcessCtor.Create();
            sut.Items = new tFlowElement[0];

            var actual = sut.GetTSequenceFlows();

            Assert.IsNotNull(actual);
            Assert.AreEqual(0, actual.Count());
        }

        [TestMethod]
        public void GetTFlowNodes()
        {
            var sut = _tProcessCtor.With(_tFlowNode1, _tFlowNode2, _tSeqFlow1, _tSeqFlow2).Create();

            var actual = sut.GetTFlowNodes();

            Assert.IsNotNull(actual);
            Assert.AreEqual(2, actual.Count());
            Assert.AreEqual(_tFlowNode1, actual.ElementAt(0));
            Assert.AreEqual(_tFlowNode2, actual.ElementAt(1));
        }

        [TestMethod]
        public void GetTSequenceFlows()
        {
            var sut = _tProcessCtor.With(_tFlowNode1, _tFlowNode2, _tSeqFlow1, _tSeqFlow2).Create();

            var actual = sut.GetTSequenceFlows();

            Assert.IsNotNull(actual);
            Assert.AreEqual(2, actual.Count());
            Assert.AreEqual(_tSeqFlow1, actual.ElementAt(0));
            Assert.AreEqual(_tSeqFlow2, actual.ElementAt(1));
        }
    }
}